package com.tmt.paymentcenter.web.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;


import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 帐户资金变动历史记录
 */
@Getter
@Setter
@Entity
@EntityListeners({AuditingEntityListener.class})
public class AccountChangeHistory extends BaseCreator implements Serializable {

    /**
     * 账户余额变动额度，增加为正数，减少为负数。
     */
    @Column(nullable = false)
    private BigDecimal amount = BigDecimal.ZERO;

    /**
     * 变动后账户余额。
     */
    @Column(nullable = false)
    private BigDecimal balanceAfterChanged;

    /**
     * 余额变动的账户
     */
    @ManyToOne(cascade = {CascadeType.REFRESH}, optional = false)
    @JoinColumn(name="account_id", nullable = false)
    private Account account;

    /**
     * 关联的交易记录
     */
    @OneToOne
    @JoinColumn(name="tradeDetailHistory_id")
    private TradeDetailHistory tradeDetailHistory;

}
